<?php if (!defined('THINK_PATH')) exit();?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="__PUBLIC__/css/common.css">
<link rel="stylesheet" href="__PUBLIC__/css/main.css">
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript"
	src="__PUBLIC__/js/colResizable-1.3.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

<style type="text/css">
div {
	width: 100%;
}
</style>

<script type="text/javascript">
      $(function(){  
        $(".list_table").colResizable({
          liveDrag:true,
          gripInnerHtml:"<div class='grip'></div>", 
          draggingClass:"dragging", 
          minWidth:30
        }); 
        
      }); 
   </script>
<title>查看首页</title>


</head>
<body>
<!--
 登陆成功<?php echo ($_SESSION['user']['username']); ?>
 -->
<div id="forms" class="mt10">
<div class="box">
<div class="box_border">
<div class="box_center"><!-- onSubmit="return onSub();"  -->
<form action="<?php echo U('/Home/homeAdd');?>" id="form"
	class="jqtransform" method="post" enctype="multipart/form-data">
<table>
	<tbody>
		<tr>
			<td>
			<table class="form_table pt15 pb15" width="100%" border="0"
				cellpadding="0" cellspacing="0">
				<tr>
					<td class="td_right">标题首页:</td>
					<td class=""><input type="text" name="title" id="title"
						class="input-text lh30" size="40"> <input type="hidden"
						name="home" id="home" value="0"> <input type="hidden" name="type"
						id="type" value="0"></td>
				</tr>
				<tr>
					<td class="td_right">上传图片:</td>
					<td><a href="javascript:();" class="btn btn-success"
						onclick="addPic()">添加图片</a></td>
				</tr>
				<tr>
					<td class="td_right"></td>
					<td>
					<div id="picDiv" class="span12"></div>
					</td>
				</tr>
				<tr>
					<td class="td_right"></td>
					<td class="">
					<div id="test" style="color: red;"></div>
					</td>
				</tr>
				<tr>
					<td class="td_right">&nbsp;</td>
					<td class=""><input type="button" class="btn btn82 btn_save2"
						onclick="onSub1();" value="保存"> <!--<input type="submit" name="button" class="btn btn82 btn_save2" value="保存"> 
                    --><input type="reset" name="button"
						class="btn btn82 btn_res" value="重置"></td>
				</tr>
			</table>
			</td>
		</tr>
	</tbody>
</table>
</form>

</div>
</div>
</div>
</div>
<script type="text/javascript">
	    function addPic(){
			$('#picDiv').append('<div class="clearfix" style="position:relative;height:32px;"><input style="width:280px;position:static;" onchange="checkPic(this)" type="file" name="img[]"/><a href="javascript:();" onclick="javascript:$(this).parent().remove();">移除</a><span class="required picError"></span></div>');
		}
		//提交前执行
		function onSub1(){
			var title = $("input[name='title']").val();
			var img = $("input[name='img[]']").val();
			//判断用户名不能为空
			if(title == ""){
				$("#test").html("标题不能为空!");
				return false;
			}else{
				$("#test").html("");
			}
			var image = 0;
			$("*[name='img[]']").each(function(index,item){
				var img_reg = /^$|^(([a-zA-Z0-9_]+):(\\.+))|([a-zA-Z0-9_]+)(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$/;
				var imgs = $(this).val().trim();
				if(!img_reg.test(imgs)){
					image = 1;
				}else{
					$("#test").html("");
				}
		    });
			if(image == 1){
				$("#test").html("图片格式错误!");
				return false;
			}else{
				$("#test").html("");
			}
			$("#form").submit();
		}
	 </script>
</body>
